package org.dashboard.shared.serversup;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Rune
 * Date: 6/19/11
 * Time: 6:39 PM
 */
public class ServerCluster implements Serializable{
    private String name;
    private String alarmSound;
    private List<Server> servers = new ArrayList<Server>();

    public ServerCluster(String name, String alarmSound){
        this.name = name;
        this.alarmSound = alarmSound;
    }

    public String getName() {
        return name;
    }

    public String getAlarmSound() {
        return alarmSound;
    }

    public void addServer(Server server){
        servers.add(server);
    }

    public List<Server> getServers()  {
        return servers;
    }

    /**
     * If just one of the servers in the cluster is online the method returns true;
     *
     * @return
     */
    public boolean isOnline(){
        for(Server server : getServers()){
            if(server.isOnline()){
                return true;
            }
        }
        return false;
    }

}
